/******************************************************************************

  File Name     : hinnie_model.h
  Version       : Initial Draft
  Author        : tongzhilin
  Created       : 2020/8/6
  Last Modified :
  Description   : hinnie_model
  Function List :
  History       :
  1.Date        : 2020/8/6
    Author      : tongzhilin
    Modification: Created file

******************************************************************************/
#pragma once
#include "mp_common.h"
#include "hi_nnie.h"
#include "mpi_nnie.h"

class HinnieModel
{
public:
    HinnieModel();
    virtual ~HinnieModel();

    static std::shared_ptr<HinnieModel> make_from_file(const char* _pstFileName, INT32 _s32BatchNum =1);
    static std::shared_ptr<HinnieModel> make_from_binary_stream(const UCHAR* _pstStream, INT32 _s32Size, INT32 _s32BatchNum = 1);

    INT32 get_input_blob_num() const { return m_s32InputBlobNum;}
    INT32 get_output_blob_num() const { return m_s32OutputBlobNum;}

    SVP_NNIE_NODE_S get_input_node(INT32 _no) const
    {
        return m_stModelNnie.astSeg[0].astSrcNode[_no];
    }
    SVP_NNIE_NODE_S get_output_node(INT32 _no) const
    {
        return m_stModelNnie.astSeg[0].astDstNode[_no];
    }
    SVP_NNIE_MODEL_S* get_hinnie_model() 
    {
        return &m_stModelNnie;
    }
    std::vector<UINT64> get_query_time()
    {
        return m_u64vQueryTimes;
    }

private:
    void model_init();
    void calculate_query_time();

    SVP_MEM_INFO_S          m_stModelRaw;       //ori model in mem
    SVP_NNIE_MODEL_S        m_stModelNnie;      //load ori model return nnie model
    INT32                   m_s32InputBlobNum;      //input blob num
    INT32                   m_s32OutputBlobNum;     //output blob num
    std::vector<UINT64>     m_u64vQueryTimes;
    INT32                   m_s32BatchNum=1;
};

